# 周K、月K、年K数据表定义
class KLineData(Model):
    id = AutoField(primary_key=True)
    stock_code = CharField(index=True)
    trade_date = DateTimeField(index=True)  # 聚合到的时间点
    open = FloatField()
    high = FloatField()
    low = FloatField()
    close = FloatField()
    pre_close = FloatField(null=True)
    change = FloatField(null=True)
    pct_chg = FloatField(null=True)
    vol = FloatField(null=True)
    amount = FloatField(null=True)
    type = CharField(choices=[("W", "周K"), ("M", "月K"), ("Y", "年K")])  # 区分类型

    class Meta:
        database = db
        table_name = "kline_data"
